from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions
from selenium.webdriver.support.wait import WebDriverWait

from Web_PO.PO_WeChat.po.BaseDriver import BaseDriver



class ContactPage(BaseDriver):
    def assert_name(self, name):
        #
        ele = (By.CSS_SELECTOR, '.js_list td:nth-child(2)')

        # 显示等待直到页面出现
        WebDriverWait(self.driver, 10).until(
            expected_conditions.visibility_of_element_located(ele))


        get_element =(By.CSS_SELECTOR, '.js_list td:nth-child(2)')
        next_element =(By.XPATH, "//*[@class='ww_pageNav_info_arrowWrap js_next_page']")

        return self.find_name(get_element,next_element,name)



        # while True:
        #     result = []
        #     ele = self.driver.find_elements(By.CSS_SELECTOR, '.js_list td:nth-child(2)')
        #     for e in ele:
        #         result.append(e.text)
        #     print(result)
        #     if name in result:
        #         break
        #     else:
        #         time.sleep(2)
        #         ele = self.driver.find_elements(By.XPATH, "//*[@class='ww_pageNav_info_arrowWrap js_next_page']")
        #         ele[0].click()
        # return result